﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

// 持续性AOE伤害
public class SkillLogicDuringAOE : SkillLogicBase
{
    protected override void initTimeLine()
    {
        _timeLine.AddEvent(0, 0, onSkillStart);
        _timeLine.AddEvent(0, 20, onAni); // 播动画
        // 播放粒子特效
        _timeLine.AddEvent(0.42192f, 1, onParticle);
        // 生成结算物
        _timeLine.AddEvent(0.42192f, 1, onCalcObject);
        // 恢复到idle状态
        _timeLine.AddEvent(1.0f, 20, onAniEnd);
        // 音效
        _timeLine.AddEvent(1.0f, 0, onSkillEnd);
    }

    private void onCalcObject(int calcObjId)
    {
        var data = CalcObjTable.Instance[calcObjId];
        if (data == null)
        {
            return;
        }

        GameObject obj = new GameObject("DuringCalc");
        obj.transform.position = _owner.transform.Find("Slot_Center").position;

        var calcObj = obj.AddComponent<DuringCalcObject>();
        calcObj.Init(_owner, data.Radius, data.HitRate, data.DuringTime, onSkillHit);
    }


    // 伤害计算方式
    private void onSkillHit(List<Creature> hitList)
    {
        DamageMgr.Instance.PhysicsDamage(_owner, hitList, _skillObject);
    }

}
